<template>
    <div>
        <el-button @click="showDialog('insert')" class="slot-btn-top" type="primary" size="small">添加</el-button>
        <el-input placeholder="请输入浆站名" v-model="search.name" class="inputSuffix">
            <el-button slot="append" icon="el-icon-search" @click="searchSubmit"></el-button>
        </el-input>
        <el-table :data="dataList" stripe border :height="tableHeight" :header-cell-style="getRowClass" v-loading='loading'>
            <el-table-column fixed type="index" label="*"  min-width="40"></el-table-column>
            <el-table-column prop="name" label="浆站名称"  min-width="100"></el-table-column>
            <el-table-column prop="address" label="浆站地址"  min-width="240"></el-table-column>
            <el-table-column prop="linkman" label="联系人"   min-width="80"></el-table-column>
            <el-table-column prop="linkmanPhone" label="联系电话"  min-width="120"></el-table-column>
            <el-table-column prop="headNurse" label="护士长"  min-width="120"></el-table-column>
            <el-table-column prop="headNursePhone" label="护士长联系方式"  min-width="120"></el-table-column>
            <el-table-column prop="gsCode" label="工商编号"  min-width="90"></el-table-column>
            <el-table-column prop="taxCode" label="税务编号"  min-width="110"></el-table-column>
            <el-table-column prop="transport" label="交通方式"  min-width="100"></el-table-column>
            <el-table-column prop="distance" label="距离"  min-width="90"></el-table-column>
            <el-table-column fixed="right" label="操作"  align="right" width="200">
                <template slot-scope="scope">
                    <el-button @click="showDialog('update',scope.row)" type="text" size="mini">编辑</el-button>
                    <el-button @click="deleteList(scope.row)" type="text" size="mini">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"></el-pagination>
        <el-dialog :title="dialog.title" width="600" top="30px" :visible.sync="dialog.isShow" :close-on-click-modal="false" v-dialogDrag>
            <el-tabs v-model="dialog.activeName" @tab-click="handleClick">
                <el-tab-pane label="基本信息" name="fifth">
                    <el-form :inline="true" class="demo-form-inline" v-model="dialog.formData" label-position="right" label-width="180px">
                        <el-form-item label="浆站名称"><el-input v-model="dialog.formData.name" ></el-input></el-form-item>
                        <el-form-item label="浆站地址"><el-input v-model="dialog.formData.address" ></el-input></el-form-item>
                        <el-form-item label="联系人"><el-input v-model="dialog.formData.linkman" ></el-input></el-form-item>
                        <el-form-item label="联系电话"><el-input v-model="dialog.formData.linkmanPhone" ></el-input></el-form-item>
                        <el-form-item label="护士长"><el-input v-model="dialog.formData.headNurse" ></el-input></el-form-item>
                        <el-form-item label="护士长联系方式"><el-input v-model="dialog.formData.headNursePhone" ></el-input></el-form-item>
                        <el-form-item label="工商编号"><el-input v-model="dialog.formData.gsCode" ></el-input></el-form-item>
                        <el-form-item label="税务编号"><el-input v-model="dialog.formData.taxCode" ></el-input></el-form-item>
                        <el-form-item label="交通方式"><el-input v-model="dialog.formData.transport" ></el-input></el-form-item>
                        <el-form-item label="距离">
                            <el-input v-model="dialog.formData.distance" class="inputSuffix">
                                <el-button slot="append">km</el-button>
                            </el-input>
                        </el-form-item>
                    </el-form>
                    <div style="text-align:center;"><el-button @click="addUpdate" type="primary">确 定</el-button></div>
                </el-tab-pane>
                <el-tab-pane label="机器列表" name="first" v-if='dialog.title.indexOf("编辑")>-1'>
                    <el-button @click="showDialog2('insert')" class="slot-btn-top" type="primary" size="small">新增</el-button>
                     <!-- 查询 -->
                    <el-popover placement="bottom-start" width="1000" style="box-shadow: 0 0 8px rgba(0,0,0,.5);" trigger="click">
                        <el-form :inline="true" :model="machine.search">
                                <el-form-item label="出厂编号:" >
                                    <el-input v-model="machine.search.factoryCode" style="width: 100px;"></el-input>
                                </el-form-item>
                                <el-form-item label="浆站自编号:">
                                    <el-input v-model="machine.search.stationCode" style="width: 100px;"></el-input>
                                </el-form-item>
                                <el-form-item label="机器状态:">
                                    <el-select v-model="machine.search.state" placeholder="请选择">
                                        <el-option label="【空】" value=""></el-option>
                                        <el-option label="在用" :value="1"></el-option>
                                        <el-option label="停用" :value="0"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-button type="primary" @click="searchMachine" icon="el-icon-search">查询</el-button>
                            </el-form>
                        <el-button slot="reference" type="primary">查询</el-button>
                    </el-popover>
                    <el-table :data="machine.list" stripe border   :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*"  min-width="40"></el-table-column>
                        <el-table-column prop="nameName.type" label="机器名称"  min-width="100"></el-table-column>
                        <el-table-column prop="nameName.code" label="机器型号"  min-width="100"></el-table-column>
                        <el-table-column prop="factoryCode" label="出厂编号"   min-width="100"></el-table-column>
                        <el-table-column prop="stationCode" label="浆站自编号"  min-width="100"></el-table-column>
                        <el-table-column prop="startTime" label="启用时间"  min-width="140"></el-table-column>
                        <el-table-column prop="endTime" label="停用时间"  min-width="140"></el-table-column>
                        <el-table-column prop="firstDeliver" label="首次交付人"  min-width="90"></el-table-column>
                        <el-table-column prop="firstTrain" label="首次培训人"  min-width="90"></el-table-column>
                        <el-table-column prop="state" label="机器状态"   min-width="100">
                            <template slot-scope="scope">
                                <el-tag v-if="scope.row.state===1" type="success">在用</el-tag>
                                <el-tag  v-if="scope.row.state===0" type="info">停用</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column prop="creatorName" label="创建人"  min-width="90"></el-table-column>
                        <el-table-column prop="createTime" label="创建时间"  min-width="140"></el-table-column>
                        <el-table-column fixed="right" label="操作"  align="right" width="100">
                            <template slot-scope="scope">
                                <el-button @click="showDialog2('update',scope.row)" type="text" size="mini">编辑</el-button>
                                <el-button @click="deleteMachine(scope.row)" type="text" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange1" @current-change="handleCurrentChange1" :current-page="machine.pagination.currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="machine.pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="machine.pagination.total"></el-pagination>
                </el-tab-pane>
                <el-tab-pane label="旅店列表" name="second" v-if='dialog.title.indexOf("编辑")>-1'>
                    <el-button @click="showDialog2('insert')" class="slot-btn-top" type="primary" size="small">新增</el-button>
                    <el-table :data="hotel.list" stripe border   :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*"  min-width="40"></el-table-column>
                        <el-table-column prop="name" label="旅店名称"  min-width="100"></el-table-column>
                        <el-table-column prop="address" label="地址"  min-width="100"></el-table-column>
                        <el-table-column prop="phone" label="联系电话"   min-width="100"></el-table-column>
                        <el-table-column prop="price" label="价格"  min-width="100"></el-table-column>
                        <el-table-column prop="creatorName" label="创建人"  min-width="90"></el-table-column>
                        <el-table-column prop="createTime" label="创建时间"  min-width="140"></el-table-column>
                        <el-table-column fixed="right" label="操作"  align="right" width="100">
                            <template slot-scope="scope">
                                <el-button @click="showDialog2('update',scope.row)" type="text" size="mini">编辑</el-button>
                                <el-button @click="deleteMachine(scope.row)" type="text" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="自修人员" name="third" v-if='dialog.title.indexOf("编辑")>-1'>
                    <el-button @click="showDialog2('insert')" class="slot-btn-top" type="primary" size="small">新增</el-button>
                    <el-table :data="selfRepair.list" stripe border   :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*"  min-width="40"></el-table-column>
                        <el-table-column prop="name" label="自修人员名字"  min-width="100"></el-table-column>
                        <el-table-column prop="position" label="职务"  min-width="100"></el-table-column>
                        <el-table-column prop="phone" label="联系电话"   min-width="100"></el-table-column>
                        <el-table-column prop="creatorName" label="创建人"  min-width="90"></el-table-column>
                        <el-table-column prop="createTime" label="创建时间"  min-width="140"></el-table-column>
                        <el-table-column fixed="right" label="操作"  align="right" width="100">
                            <template slot-scope="scope">
                                <el-button @click="showDialog2('update',scope.row)" type="text" size="mini">编辑</el-button>
                                <el-button @click="deleteMachine(scope.row)" type="text" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="浆站照片" name="fourth" v-if='dialog.title.indexOf("编辑")>-1'>
                    <el-button @click="showDialog2('insert')" class="slot-btn-top" type="primary" size="small">新增</el-button>
                    <el-table :data="stationPhoto.list" stripe border   :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*"  min-width="40"></el-table-column>
                        <el-table-column prop="name" label="图片名称"  min-width="100"></el-table-column>
                        <el-table-column prop="path" label="图片路径"  min-width="100"></el-table-column>
                        <el-table-column prop="creatorName" label="创建人"  min-width="90"></el-table-column>
                        <el-table-column prop="createTime" label="创建时间"  min-width="140"></el-table-column>
                        <el-table-column fixed="right" label="操作"  align="right" width="160">
                            <template slot-scope="scope">
                                <el-button @click="showDialog3('watch',scope.row)" type="text" size="mini">查看图片</el-button>
                                <el-button @click="deleteMachine(scope.row)" type="text" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
        </el-dialog>
        <el-dialog :title="dialog2.title" width="600" top="30px" :visible.sync="dialog2.isShow" :close-on-click-modal="false" v-dialogDrag>
            <div v-if="dialog.activeName==='first'">
                <el-form :inline="true" class="demo-form-inline" v-model="machine.formData" label-position="right" label-width="180px">
                    <el-form-item label="机器名称">
                        <el-select v-model="machine.formData.name"   placeholder="请选择" >
                            <el-option v-for="item in allMachineType" :key="item.id" :label="item.type" :value="item.id" ></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="机器型号"><el-input v-model="machine.formData.type" disabled></el-input></el-form-item>
                    <el-form-item label="出厂编号"><el-input v-model="machine.formData.factoryCode" ></el-input></el-form-item>
                    <el-form-item label="浆站自编号"><el-input v-model="machine.formData.stationCode" ></el-input></el-form-item>
                    <el-form-item label="启用时间">
                        <el-date-picker  v-model="machine.formData.startTime" type="datetime" placeholder="选择启用时间" class="inputSuffix"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="停用时间">
                        <el-date-picker  v-model="machine.formData.endTime" type="datetime" placeholder="选择停用时间" class="inputSuffix"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="首次交付人"><el-input v-model="machine.formData.firstDeliver" ></el-input></el-form-item>
                    <el-form-item label="首次培训人"><el-input v-model="machine.formData.firstTrain" ></el-input></el-form-item>
                    <el-form-item label="机器状态">
                        <el-select v-model="machine.formData.state" placeholder="请选择">
                            <el-option label="在用" :value="1"></el-option>
                            <el-option label="停用" :value="0"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="创建人" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="machine.formData.creatorName" disabled></el-input></el-form-item>
                    <el-form-item label="创建时间" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="machine.formData.createTime" disabled></el-input></el-form-item>
                </el-form>
            </div>
            <div v-else-if="dialog.activeName==='second'">
                 <el-form :inline="true" class="demo-form-inline" v-model="hotel.formData" label-position="right" label-width="180px">
                    <el-form-item label="旅店名称"><el-input v-model="hotel.formData.name" ></el-input></el-form-item>
                    <el-form-item label="地址"><el-input v-model="hotel.formData.address" ></el-input></el-form-item>
                    <el-form-item label="联系电话"><el-input v-model="hotel.formData.phone" ></el-input></el-form-item>
                    <el-form-item label="价格"><el-input v-model="hotel.formData.price" ></el-input></el-form-item>
                    <el-form-item label="创建人" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="hotel.formData.creatorName" disabled></el-input></el-form-item>
                    <el-form-item label="创建时间" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="hotel.formData.createTime" disabled></el-input></el-form-item>
                </el-form>
            </div>
             <div v-else-if="dialog.activeName==='third'">
                 <el-form :inline="true" class="demo-form-inline" v-model="selfRepair.formData" label-position="right" label-width="180px">
                    <el-form-item label="自修人员名字"><el-input v-model="selfRepair.formData.name" ></el-input></el-form-item>
                    <el-form-item label="职务"><el-input v-model="selfRepair.formData.position" ></el-input></el-form-item>
                    <el-form-item label="联系电话"><el-input v-model="selfRepair.formData.phone" ></el-input></el-form-item>
                    <el-form-item label="创建人" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="selfRepair.formData.creatorName" disabled></el-input></el-form-item>
                    <el-form-item label="创建时间" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="selfRepair.formData.createTime" disabled></el-input></el-form-item>
                </el-form>
            </div>
            <div v-else-if="dialog.activeName==='fourth'">
                 <el-form :inline="true" class="demo-form-inline" v-model="stationPhoto.formData" label-position="right" label-width="180px">
                    <el-form-item label="图片名称"><el-input v-model="stationPhoto.formData.name" ></el-input></el-form-item>
                    <el-form-item label="图片上传" class="input100">
                        <el-upload
                            :multiple="true"
                            class="imageUpload"
                            :action="stationPhoto.actionUrl"
                            :show-file-list="false"
                            :on-success="handleAvatarSuccess"
                            accept="image/jpeg,image/gif,image/png"
                            :before-upload="beforeAvatarUpload"
                        >
                        <img v-if="stationPhoto.formData.path" :src="stationPhoto.formData.path" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>
                    </el-form-item>
                    <el-form-item label="创建人" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="stationPhoto.formData.creatorName" disabled></el-input></el-form-item>
                    <el-form-item label="创建时间" v-if="dialog2.title.indexOf('修改')>-1"><el-input v-model="stationPhoto.formData.createTime" disabled></el-input></el-form-item>
                </el-form>
            </div>
            <div slot="footer" class="dialog-footer" style="text-align: center;">
                <el-button @click="addUpdateMachine" type="primary">确 定</el-button>
            </div>
        </el-dialog>
        <el-dialog title="图片查看"  width="600" :visible.sync="dialog3.isShow"  v-dialogDrag :append-to-body="true" :close-on-click-modal='false'>
            <div class="boxImge">
                <img :src="dialog3.imageUrl" alt="">
            </div>
        </el-dialog>
    </div>
</template>
<script>
import postSaleApi from '@/axios/postSale.js'
import baseHttp from '@/axios/baseHttp.js'
export default {
    data(){
        return {
            tableHeight:document.documentElement.clientHeight - 140,
            tableDialogHeightTabPane:{/**dialog style */
                height: (document.documentElement.clientHeight - 300) + 'px',
                overflowY: 'auto'
            },
            dataList:[],
            search:{
                name:''
            },
            loading:false,
            pagination:{
                currentPage:1,
                pageSize:10,
                total:0
            },
            dialog:{
                title:'',
                isShow:false,
                formData:{},
                pid:'',
                activeName:'fifth',
            },
            machine:{/**机器 */
                list:[],
                search:{
                    factoryCode:'',
                    stationCode:'',
                    state:''
                },
                pagination:{
                    currentPage:1,
                    pageSize:10,
                    total:0
                },
                formData:{}
            },
            hotel:{/**旅店 */
                list:[],
                formData:{}
            },
            selfRepair:{/**自修人员 */
                list:[],
                formData:{}
            },
            stationPhoto:{/**浆站照片 */
                list:[],
                formData:{},
                actionUrl:baseHttp.imgUpload()
            },
            dialog2:{
                title:'',
                isShow:false,
            },
            dialog3:{
                isShow:false,
               imageUrl:''
            },
            allMachineType:[]/**所有机型 */

        }
    },
    watch:{
        'machine.formData.name'(newValue,oldValue){
            let self = this;
            self.allMachineType.forEach(item=>{
                if(item.id===newValue){
                    self.machine.formData.type = item.code;
                }
            })
        }
    },
    created(){
        this.getDatalist();
    },
    methods:{
        getDatalist(){
            let self = this;
            let data = {
                currentPage:self.pagination.currentPage,
                pageSize:self.pagination.pageSize,
                name:self.search.name
            }
            self.loading = true;
            postSaleApi.customerInfoList(data).then(res=>{
               self.dataList=res.content.records;
               self.pagination.total = res.content.total;
                self.loading = false;
            },error=>{
                self.loading = false;
            })
        },
        handleSizeChange(size){
            let self = this;
            self.pagination.pageSize=size;
             self.getDatalist();
        },
        handleCurrentChange(current){
            let self = this;
            self.pagination.currentPage=current;
            self.getDatalist();
        },
         handleSizeChange1(size){
            let self = this;
            self.machine.pagination.pageSize=size;
             self.getMachineList();
        },
        handleCurrentChange1(current){
            let self = this;
            self.machine.pagination.currentPage=current;
            self.getMachineList();
        },
        searchSubmit(){
            let self = this;
            self.pagination.currentPage=1;
            self.getDatalist();
        },
        showDialog(type,row){
            let self = this;
            self.dialog.title = `${type==='insert'?'新增':'编辑'}客户信息`;
            self.dialog.isShow = true;
            self.dialog.activeName = 'fifth';
            if(type==='insert'){
                self.dialog.formData={}
            }else{
                self.dialog.formData =  row;
                self.dialog.pid = row.id;
                self.getMachineList();
                self.getAllMachine();
            }

        },
        deleteList(row){
            let self = this;
            self.$confirm('是否删除客户基础信息?', '提示', {
            confirmButtonClass: 'el-button--warning'
            }).then(() => {
                postSaleApi.deleteCustomerInfo(row.id).then(res=>{
                    self.$message.success(`客户基础删除成功`);
                    self.getDatalist();
                },error=>{
                    self.$message.error(`客户基础删除失败`);
                })
            }).catch(() => {})
        },
        addUpdate(){
           let self = this;
           let type = self.dialog.title.indexOf('新增')>-1?'insert':'update';
            postSaleApi.addUpDateCustomerInfo(type,self.dialog.formData).then(res=>{
                self.$message.success(`${self.dialog.title}成功`);
                 self.getDatalist();
                 self.dialog.isShow = false;
            })
        },
        getAllMachine(){
            let self = this;
            postSaleApi.allMachineType().then(res=>{
                self.allMachineType = res.content;
            })
        },
        showDialog2(type,row){/**新增或修改机器列表弹框 */
            let self = this;
            switch(self.dialog.activeName){
                case 'first':
                    self.dialog2.title = `${type==='insert'?'新增':'修改'}机器`;
                    type==='update'?self.machine.formData={...row}:'';
                    self.machine.formData.name=Number(self.machine.formData.name);
                    self.getAllMachine();
                    break;
                case 'second':
                    self.dialog2.title = `${type==='insert'?'新增':'修改'}旅店信息`;
                    self.hotel.formData = type==='insert'?{
                        pid:self.dialog.pid,
                        name:null,
                        address:null,
                        phone:null,
                        price:null,
                    }:row
                    break;
                case 'third':
                     self.dialog2.title = `${type==='insert'?'新增':'修改'}自修人员信息`;
                    self.selfRepair.formData = type==='insert'?{
                        pid:self.dialog.pid,
                        name:null,
                        position:null,
                        phone:null
                    }:row
                    break;
                case 'fourth':
                    self.dialog2.title = `新增浆站照片`;
                    self.stationPhoto.formData = {
                        pid:self.dialog.pid,
                        name:null,
                        path:''
                    }
                    break;
            }
             self.dialog2.isShow = true;
        },
        getMachineList(){/**获取机器列表 */
            let self = this;
            let data ={
                currentPage:self.machine.pagination.currentPage,
                pageSize:self.machine.pagination.pageSize,
                factoryCode:self.machine.search.factoryCode,
                stationCode:self.machine.search.stationCode,
                state:self.machine.search.state,
                pid:self.dialog.pid
            };
            postSaleApi.machineAll(data).then(res=>{
                self.machine.list = res.content.records;
                self.machine.pagination.total = res.content.total;
            })
        },
        addUpdateMachine(){
            let self = this;
            let type = self.dialog2.title.indexOf('新增')>-1?'insert':'update';
            switch(self.dialog.activeName){
                case 'first':/**新增或修改机器列表  */
                    self.machine.formData.startTime = self.machine.formData.startTime?self.timestampToTime1(self.machine.formData.startTime,'yy-mm-dd hh:mm:ss'):null;
                    self.machine.formData.endTime = self.machine.formData.endTime?self.timestampToTime1(self.machine.formData.endTime,'yy-mm-dd hh:mm:ss'):null;
                     self.machine.formData.pid=self.dialog.pid;
                    postSaleApi.addUpdateMachine(type,self.machine.formData).then(res =>{
                        self.$message.success(`${self.dialog2.title}成功`);
                        self.getMachineList();
                        self.dialog2.isShow = false;
                    })
                    break;
                case 'second':/**新增或修改旅店基本信息 */
                    postSaleApi.addUpdateHotel(type,self.hotel.formData).then(res=>{
                        self.$message.success(`${self.dialog2.title}成功`);
                        self.getHotelList();
                        self.dialog2.isShow = false;
                    })
                    break;
                case 'third':/**新增或修改自修人员基本信息 */
                     postSaleApi.addUpdateSelfRepair(type,self.selfRepair.formData).then(res=>{
                        self.$message.success(`${self.dialog2.title}成功`);
                        self.getSelfRepairList();
                        self.dialog2.isShow = false;
                    })
                    break;
                case 'fourth':
                    postSaleApi.addStationPhoto(self.stationPhoto.formData).then(res=>{
                        self.$message.success(`${self.dialog2.title}成功`);
                        self.getStationPhotoList();
                        self.dialog2.isShow = false;
                    })
                    break;
            }

        },
        deleteMachine(row){
             let self = this;
            self.$confirm('是否删除相关信息?', '提示', {
            confirmButtonClass: 'el-button--warning'
            }).then(() => {
                switch(self.dialog.activeName){
                    case 'first':/**删除机器列表 */
                       postSaleApi.deleteMachine(row.id).then(res=>{
                            self.$message.success(`删除关联机器成功`);
                            self.getMachineList();
                        },error=>{
                            self.$message.error(`删除关联机器失败`);
                        })
                        break;
                    case 'second':/**删除旅店列表 */
                        postSaleApi.deleteHotel(row.id).then(res=>{
                            self.$message.success(`删除旅店信息成功`);
                            self.getMachineList();
                        },error=>{
                            self.$message.error(`删除旅店信息失败`);
                        })
                        break;
                     case 'third':/**删除自修人员列表 */
                          postSaleApi.deleteSelfRepair(row.id).then(res=>{
                            self.$message.success(`删除自修人员信息成功`);
                            self.getSelfRepairList();
                        },error=>{
                            self.$message.error(`删除自修人员信息失败`);
                        })
                        break;
                    case 'fourth':
                         postSaleApi.deleteStationPhoto(row.id).then(res=>{
                            self.$message.success(`删除浆站图片成功`);
                            self.getStationPhotoList();
                        },error=>{
                            self.$message.error(`删除浆站图片失败`);
                        })
                    break;
                }

            }).catch(() => {})
        },
        searchMachine(){/**机器列表点击搜索 */
            let self = this;
            self.getMachineList();
        },
        handleClick(tab, event){/**切换配置选项 */
            let self = this;
            switch(self.dialog.activeName){
                case 'first':
                    break;
                case 'second':
                    self.getHotelList()
                    break;
                case 'third':
                    self.getSelfRepairList();
                    break;
                case 'fourth':
                    self.getStationPhotoList();
                    break;
            }
        },
        getHotelList(){/**获取旅店列表 */
            let  self = this;
            postSaleApi.hotelInfoList(self.dialog.pid).then(res=>{
                self.hotel.list = res.content;
            })
        },
        getSelfRepairList(){/**获取自修人员列表 */
            let  self = this;
            postSaleApi.selfRepairList(self.dialog.pid).then(res=>{
                self.selfRepair.list = res.content;
            })
        },
        getStationPhotoList(){/**获取浆站图片列表 */
            let  self = this;
            postSaleApi.stationPhotoList(self.dialog.pid).then(res=>{
                self.stationPhoto.list = res.content;
            })
        },
        handleAvatarSuccess(res, file){
            this.stationPhoto.formData.path = res;
        },
        beforeAvatarUpload(file){
            const isJPG = file.type === 'image/jpeg';
            const isGIF = file.type === 'image/gif';
            const isPNG = file.type === 'image/png';
            const isLt2M = file.size / 1024 / 1024 < 2;

            if (!isJPG && !isGIF && !isPNG) {
                this.$message.error('上传图片必须是JPG/GIF/PNG/格式!');
            }
            if (!isLt2M) {
                this.$message.error('上传图片大小不能超过 2MB!');
            }
            return (isJPG || isGIF || isPNG) && isLt2M;
        },
        showDialog3(type,row){
            let self = this;
            self.dialog3.isShow = true;
            self.dialog3.imageUrl = row.path;
        }
    }
}
</script>
<style scoped>
 .boxImge{
    text-align: center;
}
.boxImge>img{
    width:100%;
}
</style>


